import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		hasLogin: false,
		userInfo: {},
		
		pictureStatus: '', //上传图片类型标记
		picturePath: '', 
		pictureBackPath: '',
		pictureBankPath: '', //银行卡路径
		
		cardIsEdit: '', //照片是否编辑状态
		editFrontImgPath: '',
		editBackImgPath: '',
		editBankImgPath: ''
		
	},
	mutations: {
		// 照片的状态
		pictureStatus(state, val){
		  state.pictureStatus = val	
		},
		// 拍照的路径
		picturePath(state, val){
		  state.picturePath = val	
		},
		pictureBackPath(state, val){
		  state.pictureBackPath = val	
		},
		pictureBankPath(state, val){
		  state.pictureBankPath = val	
		},
		
		//图片是否编辑
		cardIsEdit(state, val){
		  state.cardIsEdit = val
		},
		// 编辑后的路径
		editFrontImgPath(state, val){
			state.editFrontImgPath = val
		},
		editBackImgPath(state, val){
			state.editBackImgPath = val
		},
		editBankImgPath(state, val){
			state.editBankImgPath = val
		},
		
		login(state, provider) {
			state.hasLogin = true;
			state.userInfo = provider;
			uni.setStorage({//缓存用户登陆状态
			    key: 'userInfo',  
			    data: provider  
			}) 
			console.log(state.userInfo);
		},
		logout(state) {
			state.hasLogin = false;
			state.userInfo = {};
			uni.removeStorage({  
                key: 'userInfo'  
            })
		}
	},
	actions: {
	
	}
})

export default store
